package com.allwees.bs.c.module.product.dto;

import com.allwees.bs.core.model.product.entity.ProductModel;
import lombok.Data;

import java.io.Serializable;

/**
 * @Author Daniel
 * @Version 1.0.0
 * @Description
 * @CreateTime 2020/9/25 14:32
 */
@Data
public class MarketingInfo implements Serializable {
    private static final long serialVersionUID = -5258743960185226604L;
    private String productUuid;
    /**
     * 是否网红商品
     */
    private boolean influence;
    /**
     * 是否新手礼商品
     */
    private boolean freeGift;
    /**
     * 是否闪购商品
     */
    private boolean flash;
    /**
     * 是否热销商品
     */
    private boolean popular;

    public MarketingInfo(ProductModel product){
        if (product != null) {
            this.productUuid = product.getUuid();
            Integer marketingType = product.getMarketingType();
            this.influence = (marketingType & ProductModel.MARKETING_TYPE_1) == ProductModel.MARKETING_TYPE_1;
            this.freeGift = (marketingType & ProductModel.MARKETING_TYPE_2) == ProductModel.MARKETING_TYPE_2;
            this.flash = (marketingType & ProductModel.MARKETING_TYPE_4) == ProductModel.MARKETING_TYPE_4;
            this.popular = (marketingType & ProductModel.MARKETING_TYPE_8) == ProductModel.MARKETING_TYPE_8;
        }
    }
}
